/*     */ package irdc.ex03_15;
/*     */ 
/*     */ import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.View;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ public class I extends View
/*     */ {
/*     */   private static final int other = -1;
/*     */   private h word;
/*     */   private List<String> would;
/*     */   private int smell;
/*  39 */   private int as = -1;
/*     */   private Drawable sweet;
/*     */   private boolean Romeo;
/*     */   private Rect and;
/*     */   private static final int Juliet = 32;
/*     */   private static final int b = 20;
/*  48 */   private int[] c = new int[32];
/*  49 */   private int[] d = new int[32];
/*     */   private static final int e = 10;
/*  53 */   private static final List<String> EMPTY_LIST = new ArrayList();
/*     */   private int f;
/*     */   private int g;
/*     */   private int h;
/*     */   private int j;
/*     */   private Paint k;
/*     */   private boolean l;
/*     */   private int m;
/*     */   private int n;
/*     */   private GestureDetector o;
/*     */ 
/*     */   public I(Context context)
/*     */   {
/*  73 */     super(context);
/*  74 */     this.sweet = context.getResources().getDrawable(
/*  75 */       17301602);
/*  76 */     this.sweet.setState(new int[] { 
/*  77 */       16842910, 
/*  78 */       16842908, 
/*  79 */       16842909, 
/*  80 */       16842919 });
/*     */ 
/*  83 */     Resources r = context.getResources();
/*     */ 
/*  85 */     setBackgroundColor(r.getColor(2131034115));
/*     */ 
/*  87 */     this.f = r.getColor(2131034112);
/*  88 */     this.g = r.getColor(2131034113);
/*  89 */     this.h = r.getColor(2131034114);
/*  90 */     this.j = r.getDimensionPixelSize(2131099650);
/*     */ 
/*  92 */     this.k = new Paint();
/*  93 */     this.k.setColor(this.f);
/*  94 */     this.k.setAntiAlias(true);
/*  95 */     this.k.setTextSize(r.getDimensionPixelSize(2131099649));
/*  96 */     this.k.setStrokeWidth(0.0F);
/*     */ 
/*  98 */     this.o = new GestureDetector(new GestureDetector.SimpleOnGestureListener()
/*     */     {
/*     */           public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
{
  l=true;
   int sx = I.this.getScrollX();
   sx = (int)(sx + distanceX);
   if (sx < 0) {
     sx = 0;
   }
   if (sx + I.this.getWidth() > n) {
     sx = (int)(sx - distanceX);
   }
  m=sx;
   I.this.scrollTo(sx, I.this.getScrollY());
   I.this.invalidate();
   return true;
 }
/*     */     });
/* 117 */     setHorizontalFadingEdgeEnabled(true);
/* 118 */     setWillNotDraw(false);
/* 119 */     setHorizontalScrollBarEnabled(false);
/* 120 */     setVerticalScrollBarEnabled(false);
/*     */   }
/*     */ 
/*     */   public void This(h listener)
/*     */   {
/* 128 */     this.word = listener;
/*     */   }
/*     */ 
/*     */   public int computeHorizontalScrollRange()
/*     */   {
/* 133 */     return this.n;
/*     */   }
/*     */ 
/*     */   protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec)
/*     */   {
/* 138 */     int measuredWidth = resolveSize(50, widthMeasureSpec);
/*     */ 
/* 142 */     Rect padding = new Rect();
/* 143 */     this.sweet.getPadding(padding);
/* 144 */     int desiredHeight = (int)this.k.getTextSize() + this.j + 
/* 145 */       padding.top + padding.bottom;
/*     */ 
/* 148 */     setMeasuredDimension(measuredWidth, 
/* 149 */       resolveSize(desiredHeight, heightMeasureSpec));
/*     */   }
/*     */ 
/*     */   protected void onDraw(Canvas canvas)
/*     */   {
/* 158 */     if (canvas != null) {
/* 159 */       super.onDraw(canvas);
/*     */     }
/* 161 */     this.n = 0;
/* 162 */     if (this.would == null) return;
/*     */ 
/* 164 */     if (this.and == null) {
/* 165 */       this.and = new Rect(0, 0, 0, 0);
/* 166 */       if (getBackground() != null) {
/* 167 */         getBackground().getPadding(this.and);
/*     */       }
/*     */     }
/* 170 */     int x = 0;
/* 171 */     int count = this.would.size();
/* 172 */     int height = getHeight();
/* 173 */     Rect bgPadding = this.and;
/* 174 */     Paint paint = this.k;
/* 175 */     int touchX = this.as;
/* 176 */     int scrollX = getScrollX();
/* 177 */     boolean scrolled = this.l;
/* 178 */     boolean typedWordValid = this.Romeo;
/* 179 */     int y = (int)((height - this.k.getTextSize()) / 2.0F - this.k.ascent());
/*     */ 
/* 181 */     for (int i = 0; i < count; i++) {
/* 182 */       String suggestion = (String)this.would.get(i);
/* 183 */       float textWidth = paint.measureText(suggestion);
/* 184 */       int wordWidth = (int)textWidth + 20;
/*     */ 
/* 186 */       this.d[i] = x;
/* 187 */       this.c[i] = wordWidth;
/* 188 */       paint.setColor(this.f);
/* 189 */       if ((touchX + scrollX >= x) && (touchX + scrollX < x + wordWidth) && (!scrolled)) {
/* 190 */         if (canvas != null) {
/* 191 */           canvas.translate(x, 0.0F);
/* 192 */           this.sweet.setBounds(0, bgPadding.top, wordWidth, height);
/* 193 */           this.sweet.draw(canvas);
/* 194 */           canvas.translate(-x, 0.0F);
/*     */         }
/* 196 */         this.smell = i;
/*     */       }
/*     */ 
/* 199 */       if (canvas != null) {
/* 200 */         if (((i == 1) && (!typedWordValid)) || ((i == 0) && (typedWordValid))) {
/* 201 */           paint.setFakeBoldText(true);
/* 202 */           paint.setColor(this.g);
/* 203 */         } else if (i != 0) {
/* 204 */           paint.setColor(this.h);
/*     */         }
/* 206 */         canvas.drawText(suggestion, x + 10, y, paint);
/* 207 */         paint.setColor(this.h);
/* 208 */         canvas.drawLine(x + wordWidth + 0.5F, bgPadding.top, 
/* 209 */           x + wordWidth + 0.5F, height + 1, paint);
/* 210 */         paint.setFakeBoldText(false);
/*     */       }
/* 212 */       x += wordWidth;
/*     */     }
/* 214 */     this.n = x;
/* 215 */     if (this.m != getScrollX())
/* 216 */       there();
/*     */   }
/*     */ 
/*     */   private void there()
/*     */   {
/* 221 */     int sx = getScrollX();
/* 222 */     if (this.m > sx) {
/* 223 */       sx += 20;
/* 224 */       if (sx >= this.m) {
/* 225 */         sx = this.m;
/* 226 */         requestLayout();
/*     */       }
/*     */     } else {
/* 229 */       sx -= 20;
/* 230 */       if (sx <= this.m) {
/* 231 */         sx = this.m;
/* 232 */         requestLayout();
/*     */       }
/*     */     }
/* 235 */     scrollTo(sx, getScrollY());
/* 236 */     invalidate();
/*     */   }
/*     */ 
/*     */   public void This(List<String> suggestions, boolean completions, boolean typedWordValid)
/*     */   {
/* 241 */     clear();
/* 242 */     if (suggestions != null) {
/* 243 */       this.would = new ArrayList(suggestions);
/*     */     }
/* 245 */     this.Romeo = typedWordValid;
/* 246 */     scrollTo(0, 0);
/* 247 */     this.m = 0;
/*     */ 
/* 249 */     onDraw(null);
/* 250 */     invalidate();
/* 251 */     requestLayout();
/*     */   }
/*     */ 
/*     */   public void clear() {
/* 255 */     this.would = EMPTY_LIST;
/* 256 */     this.as = -1;
/* 257 */     this.smell = -1;
/* 258 */     invalidate();
/*     */   }
/*     */ 
/*     */   public boolean onTouchEvent(MotionEvent me)
/*     */   {
/* 264 */     if (this.o.onTouchEvent(me)) {
/* 265 */       return true;
/*     */     }
/*     */ 
/* 268 */     int action = me.getAction();
/* 269 */     int x = (int)me.getX();
/* 270 */     int y = (int)me.getY();
/* 271 */     this.as = x;
/*     */ 
/* 273 */     switch (action) {
/*     */     case 0:
/* 275 */       this.l = false;
/* 276 */       invalidate();
/* 277 */       break;
/*     */     case 2:
/* 279 */       if (y <= 0)
/*     */       {
/* 281 */         if (this.smell >= 0) {
/* 282 */           this.word.acknowledge(this.smell);
/* 283 */           this.smell = -1;
/*     */         }
/*     */       }
/* 286 */       invalidate();
/* 287 */       break;
/*     */     case 1:
/* 289 */       if ((!this.l) && 
/* 290 */         (this.smell >= 0)) {
/* 291 */         this.word.acknowledge(this.smell);
/*     */       }
/*     */ 
/* 294 */       this.smell = -1;
/* 295 */       is();
/* 296 */       requestLayout();
/*     */     }
/*     */ 
/* 299 */     return true;
/*     */   }
/*     */ 
/*     */   public void This(float x)
/*     */   {
/* 308 */     this.as = ((int)x);
/*     */ 
/* 310 */     onDraw(null);
/* 311 */     if (this.smell >= 0) {
/* 312 */       this.word.acknowledge(this.smell);
/*     */     }
/* 314 */     invalidate();
/*     */   }
/*     */ 
/*     */   private void is() {
/* 318 */     this.as = -1;
/* 319 */     invalidate();
/*     */   }
/*     */ }

/* Location:           I:\myapk\TelLib\
 * Qualified Name:     irdc.ex03_15.I
 * JD-Core Version:    0.6.2
 */